﻿



using System;
using System.Collections.Generic;
using System.ServiceModel;
using Demo.DataObjects;
using Demo.Infrastructure;

namespace Demo.ServiceContracts
{
    [ServiceContract(Namespace="http://www.demo.com")]
    public interface IModuleService
    {
        /// <summary>
        /// 创建模块
        /// </summary>
        /// <param name="name">模块名称</param>
        /// <param name="sort">排序值</param>
        void CreateModule(string name,Int32 sort = 0);

        /// <summary>
        /// 获取模块DTO
        /// </summary>
        /// <param name="name">模块名称</param>
        /// <returns></returns>
        [OperationContract()]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Get)]
        ModuleDTO GetModuleDTOWithName(string name);

        /// <summary>
        /// 获取模块DTO
        /// </summary>
        /// <param name="id">模块ID</param>
        /// <returns></returns>
        [OperationContract()]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Get)]
        ModuleDTO GetModuleDTOWithId(Int32 id);

        /// <summary>
        /// 获取所有模块
        /// </summary>
        /// <param name="userid">用户ID</param>
        /// <returns></returns>
        [OperationContract()]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Get)]
        IList<ModuleDTO> GetModuleDTOWithUserId(Int32 userid);

        /// <summary>
        /// 获取所有的模块
        /// </summary>
        /// <returns></returns>
        [OperationContract()]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Get)]
        IList<ModuleDTO> GetModuleDTO();

        /// <summary>
        /// 更改模块
        /// </summary>
        /// <param name="oldName">旧模块名称</param>
        /// <param name="newName">新模块名称</param>
        /// <returns></returns>
        [OperationContract()]
        [FaultContract(typeof(FaultData))]
        [Cache(CacheType.Remove, "GetModuleDTOWithName")]
        bool ChangeModuleWithName(string oldName, string newName);

        /// <summary>
        /// 更改名称
        /// </summary>
        /// <param name="Name">模块名称</param>
        /// <param name="oleSort">旧排序值</param>
        /// <param name="newSort">新排序值</param>
        /// <returns></returns>
        //[OperationContract()]
        //[FaultContract(typeof(FaultData))]
        //[Cache(CacheType.Remove, "GetModuleDTOWithName")]
        //bool ChangeModuleWithName(string Name,Int32 newSort);
    }
}
